import React from  'react';
import {Button} from 'antd';
import VideoPlayer from '@components/VideoPlayer/VideoPlayer.jsx';
import './scss/video.scss'
// lyg-ghyjn
export default class Home extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
        source: 'http://127.0.0.1:80/test.video/5156edu.flv'
    }
    this.srcs =   [
      "http://vjs.zencdn.net/v/oceans.mp4",
      "https://vjs.zencdn.net/v/oceans.ogv",
      "//vjs.zencdn.net/v/oceans.webm",
      'http://127.0.0.1:80/test.video/5156edu.flv',
      'http://127.0.0.1:80/test.video/lyg-ghyjn.mp3',
      'http://127.0.0.1:80/test.video/Axero-Natural (Original Mix).mp3',
      'http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8'
    ];
  }

  checkoutSrc(){
    let num = this.srcs.length - 1;
    let randomN = parseInt( (Math.random() * num) );
    console.log(randomN, this.srcs[randomN]);
    this.setState({
        source: this.srcs[randomN]
    })
  }

  render() {
    return (
        <div>
            <Button onClick={() => this.checkoutSrc()}>切换</Button>
            <div className="" style={{width: 800, height: 600, margin: '0 auto'}}>
                <VideoPlayer source={this.state.source}/>
            </div>
        </div>
    );
  }
}